#include<vector>
#include<string>
#include<stack>
#include<functional>
#include<unordered_map>
using namespace std;
class Solution {
public:
    int evalRPN(vector<string>& tokens) {
        stack<int>st;
        unordered_map<string,function<void(int ,int)>>func_map{
            {"+",[&st](int a,int b)->void{st.push(a+b);}},
            {"-",[&st](int a,int b)->void{st.push(a-b);}},
            {"*",[&st](int a,int b)->void{st.push(a*b);}},
            {"/",[&st](int a,int b)->void{st.push(a/b);}}
        };
        for(auto &e:tokens){
            if(func_map.find(e)!=func_map.end()){
                int b=st.top();st.pop();
                int a=st.top();st.pop();
                func_map[e](a,b);
            }
            else            
                st.push(stoi(e));
        }
        return st.top();
    }
};